package servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import DAO.StudentDao;
import DTO.Student;

public class RegisterServlet extends HttpServlet {
	
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
//1
	String sid=req.getParameter("sid")	;
	String username=req.getParameter("username")	;
	String password=req.getParameter("password1")	;	
	String ssuper=req.getParameter("ssuper")	;
		//2
	Student s=new Student();
	s.setsId(sid);
	s.setsName(username);;
	s.setsPassword(password);
	s.setsSuper(Integer.parseInt(ssuper));
		StudentDao sd=new StudentDao();
		int flag=sd.insertIntoStudent(s);
		if(flag==1)
		resp.sendRedirect(req.getContextPath()+"/index.html");
		else
			resp.sendRedirect(req.getContextPath()+"/register.html");
		//3
	}

}
